#include <stdio.h>
#include <string.h>
#include "ofc/DSource.h"
#include "ofc/DFile.h"

int main(int argc, char *argv[])
{
  DFile   *file = [DFile new];
  DSource *srce = [DSource new];

  char     name[] = "example.xml";

  if ([file open :name :"r"])
  {
    if ([srce set :file :name])
    {
      do                               // Do for the whole file
      {
        while (![srce isLineScanned])  // Repeat during scanning of the line
        {
          int length;

          printf("Read line:%s\n", [srce line]); // Print the remaining line

          length = strlen([srce line]);

          if (length > 10)             // Example: scan only 10 chars per time
            length = 10;

          [srce scanned :length];
        }
      }
      while ([srce nextLine]);
    }
    else
      printf("Could start sourcing \"%s\".\n", name);

    [file close];
  }
  else
    printf("Could not open \"%s\":%d.\n", name, [file error]);

  [srce free];                         // Cleanup
  [file free];

  return 0;
}

